package coroutines

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.runBlocking

fun main(){
    runBlocking {
        val ev = (1..3).asFlow().onEach { delay(100);println("Event:$it") }
        //在一个新的协程作用域中执行，这里是runblocking的作用域
        ev.launchIn(this)
    }
}